/**
 Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return true if the string is valid, and false if it's invalid.

Examples
"()"              =>  true
")(()))"          =>  false
"("               =>  false
"(())((()())())"  =>  true
 */
function validParentheses(parens) {
    const parensArr = Array.from(parens);    

    return parensArr.length & 1 ||
        parensArr.indexOf(")") === 0 ||
        parensArr.slice(-1)[0] === "("
        ? false
        : parensArr.filter(item => item === "(").length ===
              parensArr.filter(item => item === ")").length;
}